<template>
	<view>
		<image :class="className" src="/static/logo.png"></image>
		<view class="title-area">
			<text class="title">{{title}}</text>
		</view>
		<view>
			<view>{{number + 1}}</view>
			<view>{{ok ? 'YES':'NO'}}</view>
			<view>{{message1.split('').reverse().join('')}}</view>
		</view>
		
		<view>
			<button @click="handleClick('参数1')">按钮1</button>
			<button @click="handleClick(dynamicParam)">按钮2</button>
			<button @click="handleClick('参数A', '参数B', $event)">按钮3</button>
			<button @click="(e) => handleButton('点击事件',e)">带事件对象</button>
		</view>
		<view class="modelclass">
			<input v-model="message2" placeholder="edit me"/>
			<text>Message is : {{ message2 }}</text>
		</view>
		<image class="logo" src="/static/logo.png"></image>
		<view v-if="!raining">今天天气真好</view>
		<view v-if="raining">下雨天，只能在家呆着了</view>
		<view v-if="state === 'vue'">state的值是 Vue</view>
		<view>State is {{state?'vue':'APP'}}</view>
		<view>
			<view v-if="state === 'vue'">uni-app</view>
			<view v-else-if="state === 'html'"> HTML</view>
			<view v-else> APP</view>
		</view>
		
		<input v-model="message2" placeholder="edit me">
		<view>
			<text>Message is:{{message2}}</text>
		</view>
		<view class="content">
			<view v-for="item in arr" :key="item.id" style="color: #ff0000;">
				{{item.name}}
			</view>
			<view v-for="(item, index) in 4" :key="index" style="color:#00ff00;">
				<view :class="'list-' + (index % 2)">{{index % 2}}</view>
			</view>
			<view v-for="(value, name, index) in object" :key="name">
				{{index}}.{{name}}.{{value}}
			</view>
			<view v-for="item in arr" :key="item.id">
				<view style="color: #0000ff;">{{item.id}}:{{item.name}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:'Hello',
				number:1,
				ok:true,
				message1:'Hello Vue!',
				className:"smalllogo",
				message2:"",
				dynamicParam: "动态参数",
				raining: false,
				state: 'vue',
				arr:[
					{id:1,name:'uni-app'},
					{id:2,name:'HTML'}
				],
				object:{
					title:'How to lists in Vue',
					author:'Jame Doe',
					publishedAt:'2020-04-10'
				}
			}
		},
		methods: {
			open(){
				this.title = "opening a new Page";
				this.className = 'logo'
			},
			handleClick(param1, param2, event) {
				console.log("参数1：", param1)
				console.log("参数2：", param2)
				console.log("事件对象：", event)
			},
			handleButton(msg, event){
				console.log("接收的消息：", msg)
				console.log("事件对象：", event)
				console.log("按钮文本：", event.target.textContent)
			}
		}
	}
</script>

<style>
.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}
	.text-area {
		display: flex;
		justify-content: center;
	}
	.smalllogo {
		height: 50rpx;
		width: 50rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}
	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>